//
//  SHWebViewController.m
//  SDemo
//
//  Created by gg on 2018/7/20.
//  Copyright © 2018年 gg. All rights reserved.
//

#import "SHWebViewController.h"

@interface SHWebViewController () <UIWebViewDelegate>

@property(nonatomic,strong)UIWebView *webview;

@end

@implementation SHWebViewController

-(UIWebView *)webview {
    if (_webview == nil) {
        _webview = [[UIWebView alloc] init];
        _webview.delegate = self;
        _webview.backgroundColor  = [UIColor yellowColor];
        // UIWebView 滚动的比较慢，这里设置为正常速度
        _webview.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
    }
    
    return  _webview;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"UIWebView拦截URL";
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.webview];
    
    [self.webview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(64);
    }];
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
    // NSString *path = [[NSBundle mainBundle] pathForResource:@"index2" ofType:@"html"];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webview loadRequest:request];
}

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    
    return  YES;
}

-(void)webViewDidFinishLoad:(UIWebView *)webView {

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
